﻿using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using IOEntity;
using System.Collections.Generic;
namespace IODataAccess
{
    public class clsDASlideCruises
    {
        int position = 5;
        int count = 0;
        clsDAConnection con = new clsDAConnection();
        public List<clsSlideCruises> GetCruisesList(string pId, int itemWidth)
        {
            List<clsSlideCruises> list = new List<clsSlideCruises>();
            try
            {
                string str = "select Url,TieuDe from tblHinhAnh where TourID=@id";
                SqlCommand com = new SqlCommand(str, con.getCon());
                com.Parameters.AddWithValue("@id", pId);
                con.openCon();
                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    clsSlideCruises cruises = new clsSlideCruises();
                    cruises.ID = "anhgt-" + (count + 1).ToString();
                    cruises.Index = count + 1;
                    cruises.Photo = "Images/HinhAnh/" + dr.GetString(0).ToString() ;
                    cruises.Description = dr.GetString(1).ToString();

                    cruises.Position = position + "px";
                    list.Add(cruises);
                    position += itemWidth;
                    count += 1;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                con.closeCon();
            }
             return list;
        }
    }
}
